package com.juhui.macao.wxapi;


import android.os.Bundle;
import android.widget.Toast;

import com.bocmacausdk.sdk.WechatPayEntryActivity;
import com.juhui.macao.R;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseResp;

public class WXPayEntryActivity extends WechatPayEntryActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pay_result);

//        api = WXAPIFactory.createWXAPI(this, Constant.OpenWeiXinBusinessId, true);
//        api.handleIntent(getIntent(), this);

        /*BocAasPayManager.getInstence(MyApplication.getApplication()).BocAasHandleUrl(new BocAasCallBack() {
            @Override
            public void callback(String s) {
                Bundle bundle = new Bundle();
                bundle.putString("result", s);
                Intent intent = new Intent(WXPayEntryActivity.this, MainActivity.class);
                intent.putExtras(bundle);
                WXPayEntryActivity.this.startActivity(intent);

            }
        });*/
    }


//    @Override
//    protected void onNewIntent(Intent intent) {
//        super.onNewIntent(intent);
//        setIntent(intent);
//        api.handleIntent(intent, this);
//    }


    @Override
    public void onResp(BaseResp resp) {
        if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
            if (resp.errCode == 0) {
                finish();
            } else if (resp.errCode == -2) {
                Toast.makeText(this, "您已取消付款!", Toast.LENGTH_SHORT).show();
                finish();
            } else {
                Toast.makeText(this, "参数错误~~", Toast.LENGTH_SHORT).show();
                finish();
            }
        } else {
            finish();
        }

//        MyApplication.getBocInstance().BocAasHandleUrl(new BocAasCallBack() {
//            @Override
//            public void callback(String s) {
//                DebugLogUtil.getInstance().Debug(s);
//            }
//        });
    }
}